<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    // 人类 - 父类
    function Person(name, age) {
        this.name = name
        this.age = age
        this.sayName = function () {
            console.log('我的名字：', this.name)
        }
    }

    Object.assign(Person.prototype, {
        hasHands: true,
        takeThings: function () {
            console.log('我可以拿东西')
        }
    })

    // 男人 - 子类
    function Man(name, age, height) {
        this.height = height
        Person.call(this, name, age)
    }

    (function () {
        function Super() {
        }

        Super.prototype = Person.prototype
        Man.prototype = new Super()
        Man.prototype.constructor = Man
    })()

    Object.assign(Man.prototype, {
        sex: '男',
        saySex: function () {
            console.log('我的性别是', this.sex)
        }
    })

    // 男孩 - 孙子类
    function Boy(name, age, height, weight) {
        this.weight = weight
        Man.call(this, name, age, height)
    }

    (function () {
        function Super() {
        }

        Super.prototype = Man.prototype
        Boy.prototype = new Super()
        Boy.prototype.constructor = Boy
    })()

    Object.assign(Boy.prototype, {
        isBaby: true
    })

    const boy = new Boy('bob', 10, 80, 20)
    console.log(boy);
</script>
</body>
</html>
